<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>APNS Test</title>
<jsp:include page="/WEB-INF/jsp/ApnsHeader.jsp" />
<script type="text/javascript">
	$( document).ready( function(){
		$("#loginButton").click(function(){
			doLogin();
		});
		
		$("#inputId, #inputPw").keypress(function(e){
			var code = e.keyCode || e.which;
			 if(code == 13) 
			 {
				 doLogin();
			 }
		});
	});
	
	function doLogin()
	{
		APNS.util.doAjax({
			url: APNS.context.getContextUrl("/login.sd"),
			data: {
				id:$( "#inputId").val(),
				pw:$( "#inputPw").val()
			},
			complete: function(req, status) {
				
				if( status == "success") {
					var resp = JSON.parse( req.responseText);
					if( resp.result == "success")
					{
						$("#pageForm").submit();
					}
					else
					{
						alert("로그인에 실패하였습니다. 아이디와 암호를 확인해보세요");
					}
				}
			}
		});
	}
</script>
</head>
<body>
	<p>&nbsp;</p>
	<p>&nbsp;</p>
	<p>&nbsp;</p>
	<h1 style="text-align:center">Welcome to APNS Server</h1>
	<div style="text-align:center">
		<form id="pageForm" action="<%=request.getContextPath()%>/page.sd" method="post">
			<input id="inputId" type="text"/>
			<input id="inputPw" type="password"/>
			<input type="hidden" name="viewName" value="ApnsMain" />
			<input type="button" value="Login" id="loginButton" />
		</form>
	</div>
</body>
</html>